package com.wyd.qxglmybatis.controller;

import java.util.List;

import javax.annotation.Resource;

import com.wyd.qxglmybatis.model.Roles;
import com.wyd.qxglmybatis.service.IRolesService;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/roles")
public class RolesController {


    @Resource
    private IRolesService rolesService;


    @ApiOperation(value = "查询所有角色",notes = "查询所有角色")
    @GetMapping(value = "find")
    public List<Roles> findAll(){


        List<Roles> list =rolesService.findAll();

      

        return list;
    }

    @ApiOperation(value = "添加或修改角色",notes = "添加或修改角色")
    @PostMapping(value = "addOrEdit")
    public int addOrEdit(@RequestBody Roles r){

        return rolesService.addOrEditRole(r);

    }

    @ApiOperation(value = "删除角色",notes = "删除角色")
    @DeleteMapping(value = "del")
    public int del( String  id){

        return rolesService.del(id);

    }

    @ApiOperation(value = "批量删除角色",notes = "批量删除角色")
    @DeleteMapping(value = "delAll")
    public void delAll( String[]  id){

        rolesService.deleteCTQ(id);

    }

}